/****************************************************
          File Name:head.h
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Tue 12 Aug 2014 04:20:57 PM CST
*****************************************************/
#ifndef HEAD_H_
#define HEAD_H_
#include <sys/types.h>
/*
 * make a struct to contain and pass
 * parameters
 * para: can be a filepath (-f); a dirctly command (-c)
 * or manange the existed jobs (-d: delete one job; -da: delete all jobs)
 *
 * command: when the timer is active the command execute (using system() at present)
 *
 * relative_time: timer time subtract localtime
 */
typedef struct job_file
{
  pid_t pid;			// timer pid
  char *command;
  unsigned long relative_time;
} job;
/*
 * transform string to integer
 */
unsigned long transform (char *str1, char *str2, char option);

/*
 * get localtime no return 
 */
char *getlocaltime (void);

/*
 *  get and transform timer time
 *  argument from argv or read from a file adjust by the 2nd argument
 */
job gettime_cmd (const char *arg, const char *trtime, char *cmd);

/*
 * get timer time from file return in 'long' in seconds
 */
job getfromfile (const char *path);

/* 
 * get timer time from commandline argv[2]
 */
job getfromcmd (const char *cmd1, char *cmd2);

/*
 * set timer; arg contains the command and relative_time
 */
void settimer (job arg);

/*
 * get timer pid then put them into a file
 */
void showtimer (job arg, char option);
/*
 * delete timer; char *arg: -d or -da
 */

void deltimer (char *arg);

/*
 * handle error
 */
void eRR (char *func);

#endif
